/**
 * webpack-dev-middleware 是一个封装器(wrapper)，它可以把webpack 处理过的文件发送到一个server。
 * webpack-dev-server 在内部使用了它，然而它也可以作为一个单独的package 来使用，以便根据需求进行
 * 更多自定义设置；
 * 我们可以搭配一个服务器来使用它，比如express；
 */
const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const config = require('./webpack.config');
const app = express();
const compiler = webpack(config);
const middleware = webpackDevMiddleware(compiler);
app.use(middleware);

app.listen(3000, () => {
  console.log('服务器启动在3000')
})

/*const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');

const app = express();

const config = require("./webpack.config");

// 传入配置信息, webpack根据配置信息进行编译
const compiler =  webpack(config);

const middleware = webpackDevMiddleware(compiler);
app.use(middleware);

app.listen(3000, () => {
  console.log("服务已经开启在3000端口上~");
});*/
